package org.itstack.command;

import java.util.Stack;

public class RemoteControl {
    private final Stack<Command> undoStack = new Stack<>();


    public void executeCommand(Command command) {
        command.execute();
        undoStack.push(command);
    }

    public void undo() {
        if (!undoStack.isEmpty()) {
            Command command = undoStack.pop();
            command.undo();
        }
    }

    public void undoLastCommand(){
        if (!undoStack.isEmpty()) {
            Command command = undoStack.pop();
            command.undo();
        }else{
            System.out.println("No command to undo");
        }
    }
    

    


}
